/*************************************************************************
    > File Name: transTB.h
    > Author: liujing
    > Mail: jingliu.cs@gmail.com 
    > Created Time: 2014年10月21日 星期二 19时36分54秒
 ************************************************************************/

#ifndef _TRANS_TB_H_
#define _TRANS_TB_H_
#include <set>
#include <map>
#include "graph.h"
#include "reg2nfa.h"
#include <queue>
class State{
public:
	State(void);
	~State(void);
public:
	static int DFA_ID;
	int dfa_id;
	bool isEnd;
	Graph* graph;	
	set<int> nfaStateIDs;		//as the kernel set 
	set<wchar_t> adjChars;
	map<wchar_t,int> nextStates;
	State(Graph* g, set<int> nfaIDs);
	static void resetDFAID();
	int getDFAID();
	bool isEqual(State* s);
	bool isIntersect(State* s);
	State* move(wchar_t str);
	State* eclosure();
	void printState();
};
void dfs(Graph* graph,int startNode,set<int>* eSet,vector<bool>* visited);
set<wchar_t> getAdjEdges(State* s);

class TransTable{
public:
	TransTable(void);
	~TransTable(void);
public:
	TransTable(Graph* graph);
	Graph* graph;
	int stateSum;
	vector<State*> states;
	void buildTransitionTable(void);
	void printTransTable(void);
};

void handleCircles(TransTable* transtb);

#endif
